************************************************
*** REPLICATION FILE FOR STATE DISENGAGEMENT ***
*** MCALEXANDER AND RICART-HUGUET **************
************************************************


clear all
set more off  
global folder_data "C:\Users\jricart-huguet\Dropbox\FWA\data"
global folder_Stata "C:\Users\jricart-huguet\Dropbox\FWA\data\Stata"
global folder_tables "C:\Users\jricart-huguet\Dropbox\FWA\writing\tables"
global folder_figures "C:\Users\jricart-huguet\Dropbox\FWA\figures"
macro dir
cd "$folder_Stata"

use "$folder_Stata\fwa_isq.dta"

xtset district year, yearly //delta(1)
tsreport //, detail

global locfund distcoast100 natharbor_cape rivernav rugged mors_mean malaria
global soilnatres noble base sqfactor 
global socecon popl areal elf islam v28m v30m v33m v70recm


****************************
**** SUMMARY STATISTICS ****
****************************

* to avoid scientific notation, format(%20.0f) % no decimals
tabstat totneuf totperss totensei impind_p fees hec_notx  ///
$locfund $soilnatres $socecon coast_cap popeu, format(%20.2f) statistics(mean sd min max) columns(statistics)

preserve 
label var totneuf "Infrastructure expenditures (in 1910 FRA)"
label var totperss "Health staff"
label var totensei "Teachers"
label var impind_p "Head taxes on Africans (in 1910 FRA)"
label var fees "Fees from Africans not doing hard labor (in 1910 FRA)"
label var hec_notx "Chieftain hostility (no threat is 0, major threat is 4)"
label var noble "Gold, silver, or diamonds indicator"
label var base "Base metals indicator"
label var elf "Ethnic fractionalization index (pre-colonial)"
label var islam "Presence of Islam, low-medium-high (1913)"
label var v28m "Intensity of agriculture (pre-colonial)"
label var v30m "Settlement patterns (pre-colonial)"
label var v33m "Political centralization (pre-colonial)"
label var v70recm "Slavery (pre-colonial)"
label var popeu "European population (1910)"

format %20.2fc totneuf totperss totensei impind_p fees hec_notx  ///
$locfund $soilnatres $socecon coast_cap popeu

sutex2 totneuf totperss totensei impind_p fees hec_notx, varlabels /// title (Summary Statistics)
minmax  digits(2) saving(sumstats_main.tex) replace // tabular

keep if year==1925 // cross-sectional variables
sutex2 $locfund $soilnatres $socecon coast_cap popeu, varlabels /// title (Summary Statistics)
minmax  digits(2) saving(sumstats_other.tex) replace // tabular

restore 


****************
**** MODELS ****
****************

foreach var of varlist totneuf_log totperss_log totensei_log impind_p_log fees_log  {
eststo `var'_xt1: qui xtreg `var' hec_notx  $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)
eststo `var'_xt1_CCint: qui xtreg `var' hec_notx coast_cap hec_notx_x_cc  $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2 ///
, vce(cluster prov38)
eststo `var'_xt2_CCint: qui xtreg `var' hec_notx coast_cap hec_notx_x_cc  i.year i.district ///
, fe vce(cluster prov38)
eststo `var'_xt1_popeul: qui xtreg `var' hec_notx popeul hec_notx_x_popeul $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2 ///
, vce(cluster prov38)
eststo `var'_xt1_hes: qui xtreg `var' hes_notx  $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)
eststo `var'_xt2_CCint_hes: qui xtreg `var' hes_notx coast_cap hes_notx_x_cc  i.year i.district ///
, fe vce(cluster prov38)
eststo `var'_xt1_int_crop: qui xtreg `var' hec_notx capcrop hec_notx_x_capcrop  $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2 , vce(cluster prov38)
}

* R1 comment on creating hec_notx_v2 and running test
foreach var of varlist totneuf_log totperss_log totensei_log impind_p_log fees_log {
eststo `var'_xt1_CCint_v2: qui xtreg `var' hec_notx_v2 coast_cap hec_notx_v2_x_cc  $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)
eststo `var'_xt2_CCint_v2: qui xtreg `var' hec_notx_v2 coast_cap hec_notx_v2_x_cc i.year i.district, fe vce(cluster prov38)
}

* Round 1 reviewer suggestion
foreach var of varlist pac_log pam_log gardes_log  militair_log {
	eststo `var'_xt1_CCint: qui xtreg `var' hec_notx coast_cap hec_notx_x_cc $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)	
}

* Other taxation: placebo test
foreach var of varlist imppers_p impeur_p imp_rev patente1 {
capture drop `var'_log
gen `var'_log = log(`var' + 1)
eststo `var'_xt2_CCint: qui xtreg `var'_log hec_notx coast_cap hec_notx_x_cc  i.year i.district, fe vce(cluster prov38)
}


* Hostility, royaume, aceph
foreach var of varlist totneuf_log totperss_log totensei_log impind_p_log fees_log {
eststo `var'_royac1: qui xtreg `var' hec_notx anc_royaume acephale_isole $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)
eststo `var'_royac1_int: qui xtreg `var' hec_notx anc_royaume hec_notx_x_royaume acephale_isole hec_notx_x_aceph $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)
}



*********************************
*** INTERACTION EFFECTS PLOTS ***
*********************************

** Figure 3 ** 

** INTERACTION EFFECTS PLOT HOSTILITY x COAST-CAPITAL: totneuf_log
cd "$folder_figures"
xtreg totneuf_log coast_cap##c.hec_notx  $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)
margins coast_cap, at(hec_notx=(0(1)4)) // expression(exp(predict(xb)))
marginsplot, xdimension(at(hec_notx)) recast(line) recastci(rline) ciopts(lpattern(dash)) ///
title("") ytitle("Infrastructure expenditure (logged, in 1910 FRA)", size(medlarge)) xtitle("Chieftain hostility", size(medlarge)) ///
ylabel(, labsize(medlarge)) xlabel(0(1)4, labsize(medlarge)) graphregion(color(white)) ///
text(9.8 2.7 "High capacity", size(medlarge) place(r)) /// xline(1, lpattern(dash) lwidth(vthin) lcolor(gray)) 
text(6.6 2.7  "Low capacity", size(medlarge) place(r)) /// xline(5, lpattern(dash) lwidth(vthin) lcolor(gray)) 
name(margins_totneuf_log, replace) legend(off)
graph export margins_totneuf_log.pdf, replace
graph export margins_totneuf_log.eps, replace
cd "$folder_Stata"

** INTERACTION EFFECTS PLOT HOSTILITY x COAST-CAPITAL: impind_p_log
cd "$folder_figures"
xtreg impind_p_log coast_cap##c.hec_notx  $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)
margins coast_cap, at(hec_notx=(0(1)4)) // expression(exp(predict(xb)))
marginsplot, xdimension(at(hec_notx)) recast(line) recastci(rline) ciopts(lpattern(dash)) ///
title("") ytitle("Head taxes on Africans (logged, in 1910 FRA)", size(medlarge)) xtitle("Chieftain hostility", size(medlarge)) ///
ylabel(, labsize(medlarge)) xlabel(0(1)4, labsize(medlarge)) graphregion(color(white)) ///
text(12.92 2.9  "High capacity", size(medlarge) place(r)) /// xline(5, lpattern(dash) lwidth(vthin) lcolor(gray)) 
text(12.25 2.9 "Low capacity", size(medlarge) place(r)) /// xline(1, lpattern(dash) lwidth(vthin) lcolor(gray)) 
name(margins_impind_p_log, replace) legend(off)
graph export margins_impind_p_log.pdf, replace
graph export margins_impind_p_log.eps, replace
cd "$folder_Stata"

** Figure A.3 ** 

** INTERACTION EFFECTS PLOT HOSTILITY x SETTLERS: totneuf_log
cd "$folder_figures"
xtreg totneuf_log c.popeul##c.hec_notx  $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)
margins, at(hec_notx=(0 4) popeul=(1 5)) // expression(exp(predict(xb)))
marginsplot, xdimension(at(hec_notx)) recast(line) recastci(rline) ciopts(lpattern(dash)) ///
title("") ytitle("Infrastructure expenditure (logged, in 1910 FRA)", size(medlarge)) xtitle("Chieftain hostility", size(medlarge)) ///
ylabel(, labsize(medlarge)) xlabel(0(1)4, labsize(medlarge)) graphregion(color(white)) ///
text(15.5 1.4 "Many Europeans", size(medlarge) place(r)) /// xline(1, lpattern(dash) lwidth(vthin) lcolor(gray)) 
text(2.5 1.4  "Few Europeans", size(medlarge) place(r)) /// xline(5, lpattern(dash) lwidth(vthin) lcolor(gray)) 
name(margins_totneuf_log_popeul, replace) legend(off)
graph export margins_totneuf_log_popeul.pdf, replace
graph export margins_totneuf_log_popeul.eps, replace
cd "$folder_Stata"

** INTERACTION EFFECTS PLOT HOSTILITY x SETTLERS: impind_p_log
cd "$folder_figures"
xtreg impind_p_log c.popeul##c.hec_notx  $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)
margins, at(hec_notx=(0 4) popeul=(1 5)) // expression(exp(predict(xb)))
marginsplot, xdimension(at(hec_notx)) recast(line) recastci(rline) ciopts(lpattern(dash)) ///
title("") ytitle("Head taxes on Africans (logged, in 1910 FRA)", size(medlarge)) xtitle("Chieftain hostility", size(medlarge)) ///
ylabel(, labsize(medlarge)) xlabel(0(1)4, labsize(medlarge)) graphregion(color(white)) ///
text(13.1 2.2 "Many Europeans", size(medlarge) place(r)) /// xline(1, lpattern(dash) lwidth(vthin) lcolor(gray)) 
text(12.1 2.2  "Few Europeans", size(medlarge) place(r)) /// xline(5, lpattern(dash) lwidth(vthin) lcolor(gray)) 
name(margins_impind_p_log_popeul, replace) legend(off)
graph export margins_impind_p_log_popeul.pdf, replace
graph export margins_impind_p_log_popeul.eps, replace
cd "$folder_Stata"


****************
**** TABLES ****
****************


* Table 2
preserve
label var hec_notx "Chieftain hostility"
cd "$folder_tables"
esttab totneuf_log_xt1 totperss_log_xt1 ///
totensei_log_xt1 impind_p_log_xt1 fees_log_xt1 using xt1_notx.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(, elist(hec_notx \hline year \hline)) /// 
indicate("Region FE = prov_*" "Geographic controls = natharbor_cape" ///
"\shortstack[l]{Ethnic and\\socioeconomic controls} = v30m" ) /// "Colony FE = *colcode*" 
mtitles("\shortstack{Infrastructure}" "Health staff" "Teachers" "\shortstack{Head taxes}" "\shortstack[1]{Fees}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx elf popl year) keep(hec_notx elf popl year) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore

* Table 3
preserve
cd "$folder_tables"
label var hec_notx "Chieftain hostility"
label var hec_notx_x_cc "\shortstack[l]{Chieftain hostility x \\ coastal or capital district}"
esttab totneuf_log_xt1_CCint totperss_log_xt1_CCint ///
totensei_log_xt1_CCint impind_p_log_xt1_CCint fees_log_xt1_CCint using xt1_CCint_notx.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(, elist(hec_notx_x_cc \hline year \hline)) /// 
indicate("Region FE = prov_*" "Geographic controls = natharbor_cape" ///
"\shortstack[l]{Ethnic and\\socioeconomic controls} = v30m" ) /// "Colony FE = *colcode*" 
mtitles("\shortstack{Infrastructure}" "Health staff" "Teachers" "\shortstack{Head taxes}" "\shortstack[1]{Fees}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx coast_cap hec_notx_x_cc) keep(hec_notx coast_cap hec_notx_x_cc) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore

* Table 4
preserve
cd "$folder_tables"
label var hec_notx "Chieftain hostility"
label var hec_notx_x_cc "\shortstack[l]{Chieftain hostility x \\ coastal or capital district}"
esttab totneuf_log_xt2_CCint totperss_log_xt2_CCint ///
totensei_log_xt2_CCint impind_p_log_xt2_CCint fees_log_xt2_CCint using xt2_CCint_notx.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(, elist(hec_notx_x_cc \hline)) /// 
indicate("District FE = *district*" "Year FE = *year*") /// "Colony FE = *colcode*" 
mtitles("\shortstack{Infrastructure}" "Health staff" "Teachers" "\shortstack{Head taxes}" "\shortstack[1]{Fees}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx hec_notx_x_cc) keep(hec_notx hec_notx_x_cc) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore

* Table 5
preserve
cd "$folder_tables"
label var hec_notx "Chieftain hostility"
label var hec_notx_x_cc "\shortstack[l]{Chieftain hostility x \\ coastal or capital district}"
esttab impeur_p_xt2_CCint imppers_p_xt2_CCint imp_rev_xt2_CCint patente1_xt2_CCint using xt2_CCint_notx_taxplacebo.tex, replace label ///
varlabels(, elist(hec_notx_x_cc \hline)) /// 
indicate("District FE = *district*" "Year FE = *year*") /// "Colony FE = *colcode*" 
mtitles("\shortstack{Head taxes\\on Europeans}" "\shortstack{Head taxes,\\total}" "Income taxes" "\shortstack{Taxes on\\trading licenses}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx hec_notx_x_cc) keep(hec_notx hec_notx_x_cc) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore


***********************
*** APPENDIX TABLES ***
***********************

* Table A.4
preserve
cd "$folder_tables"
label var hec_notx "Chieftain hostility"
label var hec_notx_x_popeul "\shortstack[l]{Chieftain hostility x \\ number of Europeans}"
esttab totneuf_log_xt1_popeul totperss_log_xt1_popeul ///
totensei_log_xt1_popeul impind_p_log_xt1_popeul fees_log_xt1_popeul using xt1_popeul_notx.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(, elist(hec_notx_x_popeul \hline year \hline)) /// 
indicate("Region FE = prov_*" "Geographic controls = natharbor_cape" ///
"\shortstack[l]{Ethnic and\\socioeconomic controls} = v30m" ) /// "Colony FE = *colcode*" 
mtitles("\shortstack{Infrastructure}" "Health staff" "Teachers" "\shortstack{Head taxes}" "\shortstack[1]{Fees}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx popeul hec_notx_x_popeul) keep(hec_notx popeul hec_notx_x_popeul) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore

*Table A.7
preserve
label var anc_royaume "Pre-colonial kingdom indicator"
label var acephale_isole "Acephalous society indicator"
label var hec_notx "Chieftain hostility"
cd "$folder_tables"
esttab totneuf_log_royac1 totperss_log_royac1 totensei_log_royac1 impind_p_log_royac1 fees_log_royac1 using royac1_notx.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(, elist(acephale_isole \hline year \hline)) /// 
indicate("Region FE = prov_*" "Geographic controls = natharbor_cape" ///
"\shortstack[l]{Ethnic and\\socioeconomic controls} = v30m" ) /// "Colony FE = *colcode*" 
mtitles("Infrastructure" "Health staff" "Teachers" "Head taxes" "Fees") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx anc_royaume acephale_isole elf popl year) ///
keep(hec_notx anc_royaume acephale_isole elf popl year) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore

* Table A.8
preserve
label var anc_royaume "Pre-colonial kingdom indicator"
label var acephale_isole "Acephalous society indicator"
label var hec_notx "Chieftain hostility"
label var hec_notx_x_royaume "\shortstack[l]{Chieftain hostility x \\ pre-colonial kingdom}"
label var hec_notx_x_aceph "\shortstack[l]{Chieftain hostility x \\ acephalous society}"
cd "$folder_tables"
esttab totneuf_log_royac1_int totperss_log_royac1_int totensei_log_royac1_int impind_p_log_royac1_int fees_log_royac1_int using royac1_int_notx.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(, elist(hec_notx_x_aceph \hline year \hline)) /// 
indicate("Region FE = prov_*" "Geographic controls = natharbor_cape" ///
"\shortstack[l]{Ethnic and\\socioeconomic controls} = v30m" ) /// "Colony FE = *colcode*" 
mtitles("Infrastructure" "Health staff" "Teachers" "Head taxes" "Fees") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx anc_royaume hec_notx_x_royaume acephale_isole hec_notx_x_aceph elf popl year) ///
keep(hec_notx anc_royaume hec_notx_x_royaume acephale_isole hec_notx_x_aceph elf popl year) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore

* Table A.10
preserve
label var hec_notx "Chieftain hostility"
label var v33m "Pre-colonial political centralization"
cd "$folder_tables"
esttab totneuf_log_xt1 totperss_log_xt1 ///
totensei_log_xt1 impind_p_log_xt1 fees_log_xt1 using xt1_notx_fulltable.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(_cons Constant, elist(v70recm \hline hec_notx \hline year \hline)) /// 
indicate("Region FE = prov_*") /// "Colony FE = *colcode*" 
mtitles("\shortstack{Infrastructure}" "Health staff" "Teachers" "\shortstack{Head taxes}" "\shortstack[1]{Fees}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx elf popl year) /// keep(hec_notx elf popl year) 
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore

* Table A.11
preserve
label var hec_notx "Chieftain hostility"
label var hec_notx_x_cc "\shortstack[l]{Chieftain hostility x \\ coastal or capital district}"
label var v33m "Pre-colonial political centralization"
cd "$folder_tables"
esttab totneuf_log_xt1_CCint totperss_log_xt1_CCint ///
totensei_log_xt1_CCint impind_p_log_xt1_CCint fees_log_xt1_CCint using xt1_CCint_notx_fulltable.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(_cons Constant, elist(v70recm \hline hec_notx_x_cc \hline year \hline)) /// 
indicate("Region FE = prov_*") /// "Colony FE = *colcode*" 
mtitles("\shortstack{Infrastructure}" "Health staff" "Teachers" "\shortstack{Head taxes}" "\shortstack[1]{Fees}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx coast_cap hec_notx_x_cc elf popl year) /// keep(hec_notx elf popl year) 
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore

* Table A.12
preserve
label var hes_notx "Subject hostility"
cd "$folder_tables"
esttab totneuf_log_xt1_hes totperss_log_xt1_hes ///
totensei_log_xt1_hes impind_p_log_xt1_hes fees_log_xt1_hes using xt1_hes_notx.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(, elist(hes_notx \hline year \hline)) /// 
indicate("Region FE = prov_*" "Geographic controls = natharbor_cape" ///
"\shortstack[l]{Ethnic and\\socioeconomic controls} = v30m" ) /// "Colony FE = *colcode*" 
mtitles("\shortstack{Infrastructure}" "Health staff" "Teachers" "\shortstack{Head taxes}" "\shortstack[1]{Fees}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hes_notx elf popl year) keep(hes_notx elf popl year) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore


* Table A.13
preserve
cd "$folder_tables"
label var hes_notx "Subject hostility"
label var hes_notx_x_cc "\shortstack[l]{Subject hostility x \\ coastal or capital district}"
esttab totneuf_log_xt2_CCint_hes totperss_log_xt2_CCint_hes ///
totensei_log_xt2_CCint_hes impind_p_log_xt2_CCint_hes fees_log_xt2_CCint_hes using xt2_CCint_hes_notx.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(, elist(hes_notx_x_cc \hline)) /// 
indicate("District FE = *district*" "Year FE = *year*") /// "Colony FE = *colcode*" 
mtitles("\shortstack{Infrastructure}" "Health staff" "Teachers" "\shortstack{Head taxes}" "\shortstack[1]{Fees}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hes_notx hes_notx_x_cc) keep(hes_notx hes_notx_x_cc) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore

* Table A.14 (R1 comment)
preserve
cd "$folder_tables"
label var hec_notx_v2 "Chieftain hostility"
label var hec_notx_v2_x_cc "\shortstack[l]{Chieftain hostility x \\ coastal or capital district}"
esttab totneuf_log_xt1_CCint_v2 totperss_log_xt1_CCint_v2 ///
totensei_log_xt1_CCint_v2 impind_p_log_xt1_CCint_v2 fees_log_xt1_CCint_v2 using xt1_CCint_notx_v2.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(, elist(hec_notx_v2_x_cc \hline year \hline)) /// 
indicate("Region FE = prov_*" "Geographic controls = natharbor_cape" ///
"\shortstack[l]{Ethnic and\\socioeconomic controls} = v30m" ) /// "Colony FE = *colcode*" 
mtitles("\shortstack{Infrastructure}" "Health staff" "Teachers" "\shortstack{Head taxes}" "\shortstack[1]{Fees}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx_v2 coast_cap hec_notx_v2_x_cc) keep(hec_notx_v2 coast_cap hec_notx_v2_x_cc) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore



***********************************************
** DATA ANALYSIS ON DETERMINANTS OF HOSTILTY **
***********************************************

global locfund_hecdet distcoast100 natharbor_cape areal rivernav rugged mors_mean malaria
global soilnatres noble base sqfactor 
global socecon_nopop elf islam v28m v30m v70recm anc_royaume acephale_isole 
eststo hecdet1: qui xtreg hec $locfund_hecdet $soilnatres, vce(cluster prov38)
eststo hecdet2: qui xtreg hec popeul $locfund_hecdet $soilnatres $socecon_nopop year, vce(cluster prov38)
eststo hecdet3: qui xtreg hec popeul popafl $locfund_hecdet $soilnatres $socecon_nopop year prov_*, vce(cluster prov38)

esttab hecdet*, drop(*year*) $esttabformatse

* Table A.9
preserve
label var anc_royaume "Pre-colonial kingdom indicator"
label var acephale_isole "Acephalous society indicator"
label var anc_comptoir "Pre-colonial trading post indicator"
label var disttradecol1_100 "Distance from the first trading post in the colony, in 100km"
label var distcoast100 "Distance from the coast, in 100km"
label var natharbor_cape "Natural harbor or cape indicator"
label var rivernav "Navigable river indicator (1910)"
label var malaria "Malaria prevalence index (1900)"
label var noble "Gold, silver or diamonds indicator (1920)"
label var base "Base metals indicator (1920)"
label var sqfactor "Soil quality index (2000)"
label var islam "Prevalence of Islam (1910)"
label var v28m "Agriculture (none to irrigation)"
label var v30m "Settlements (nomadic to complex)"
label var v33m "Pre-colonial political centralization"
label var v70recm "Slavery (absence to prevalent)"
cd "$folder_tables"
esttab hecdet1 hecdet2 hecdet3 using hec_determinants.tex, replace label ///
varlabels(, elist(year \hline)) /// 
indicate("Region FE = prov_*") ///
nomtitles nonotes nogaps star(\dag 0.10 * 0.05 ** 0.01) /// 
order($locfund $soilnatres $socecon_nopop popeul popafl year) ///
keep($locfund $soilnatres $socecon_nopop popeul popafl year) ///
refcat(distcoast100 "\emph{\hspace{0.1cm} Geography}" ///
noble "\emph{\hspace{0.1cm} Natural resources}" /// 
soilnatres "\emph{\hspace{0.1cm} Pre-colonial socioeconomic characteristics}" ///
elf "\emph{\hspace{0.1cm} Pre-colonial socioeconomic characteristics}" ///
popeul "\emph{\hspace{0.1cm} Population}", label(".")) /// nolabel
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore

*******************************************
** OSTER BOUNDS ON OLS RESULTS Table A.3 **
*******************************************

* Infrastructure 

reg totneuf_log hec_notx $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)
ereturn list
global r2_totneuf=e(r2)

* Vary Rmax and calculate different deltas and betas

* Rmax = 1.1 * R
global r2_totneuf_max1 = $r2_totneuf * 1.1
psacalc delta hec_notx, rmax($r2_totneuf_max1) // delta = 9.53
psacalc beta hec_notx, rmax($r2_totneuf_max1) // beta = -0.41

* Rmax = 1.2 * R
global r2_totneuf_max1 = $r2_totneuf * 1.2
psacalc delta hec_notx, rmax($r2_totneuf_max1) // delta = 4.9
psacalc beta hec_notx, rmax($r2_totneuf_max1) // beta = -0.37

* Rmax = 1.5 * R
global r2_totneuf_max1 = $r2_totneuf * 1.5
psacalc delta hec_notx, rmax($r2_totneuf_max1) // delta = 2.02
psacalc beta hec_notx, rmax($r2_totneuf_max1) // beta = -0.25

* Rmax = 2 * R
global r2_totneuf_max1 = $r2_totneuf * 2
psacalc delta hec_notx, rmax($r2_totneuf_max1) // delta = 1.02
psacalc beta hec_notx, rmax($r2_totneuf_max1) // beta = -0.01

* Teachers 

reg totensei_log hec_notx $locfund $soilnatres $socecon year prov_BEN1-prov_SEN2, vce(cluster prov38)
ereturn list // 0.3 = R2_overall is the one I get if I run reg totneuf...
global r2_totensei=e(r2)

* Rmax = 1.1 * R
global r2_totensei_max1 = $r2_totensei * 1.1
psacalc delta hec_notx, rmax($r2_totensei_max1) // delta = 4.3
psacalc beta hec_notx, rmax($r2_totensei_max1) // beta = -0.06

* Rmax = 1.2 * R
global r2_totensei_max1 = $r2_totensei * 1.2
psacalc delta hec_notx, rmax($r2_totensei_max1) // delta = 2.2
psacalc beta hec_notx, rmax($r2_totensei_max1) // beta = -0.04

* Rmax = 1.3 * R
global r2_totensei_max1 = $r2_totensei * 1.3
psacalc delta hec_notx, rmax($r2_totensei_max1) // delta = 1.49
psacalc beta hec_notx, rmax($r2_totensei_max1) // beta = -0.03



************************************************
** ISQ R3 Changes to personnel and cash crops **
************************************************

* Table A.5
preserve
cd "$folder_tables"
label var hec_notx "Chieftain hostility"
label var hec_notx_x_cc "\shortstack[l]{Chieftain hostility x \\ coastal or capital district}"
esttab pac_log_xt1_CCint pam_log_xt1_CCint gardes_log_xt1_CCint militair_log_xt1_CCint using xt1_CCint_notx_personnel.tex, replace label ///
mgroups("Administrative staff" "Police force", pattern(1 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(, elist(hec_notx_x_cc \hline year \hline)) /// 
indicate("Region FE = prov_*" "Geographic controls = natharbor_cape" ///
"\shortstack[l]{Ethnic and\\socioeconomic controls} = v30m" ) /// "Colony FE = *colcode*" 
mtitles("Civilians" "Military" "Guards" "Servicemen") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx coast_cap hec_notx_x_cc) keep(hec_notx coast_cap hec_notx_x_cc) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore


* Table A.6
preserve
cd "$folder_tables"
label var hec_notx "Chieftain hostility"
label var hec_notx_x_capcrop "\shortstack[l]{Chieftain hostility x \\ capital or cash crop district}"
label var crop "Cash crop district indicator"
esttab totneuf_log_xt1_int_crop totperss_log_xt1_int_crop ///
totensei_log_xt1_int_crop impind_p_log_xt1_int_crop fees_log_xt1_int_crop using xt1_int_notx_crop.tex, replace label ///
mgroups("Public investments" "Revenue extraction", pattern(1 0 0 1 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
varlabels(, elist(hec_notx_x_capcrop \hline year \hline)) /// 
indicate("Region FE = prov_*" "Geographic controls = natharbor_cape" ///
"\shortstack[l]{Ethnic and\\socioeconomic controls} = v30m" ) /// "Colony FE = *colcode*" 
mtitles("\shortstack{Infrastructure}" "Health staff" "Teachers" "\shortstack{Head taxes}" "\shortstack[1]{Fees}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// nomtitles 
order(hec_notx capcrop hec_notx_x_capcrop) keep(hec_notx capcrop hec_notx_x_capcrop) ///
b(2) se(2) stats(N r2_o, fmt(0 2) labels("Districts (N)" "\(R^{2}\)")) //
cd "$folder_Stata"
restore

